From: kfraser@localhost.localdomain Date: Tue, 31 Oct 2006 15:54:03 +0000 (+0000) Subject: Clean up recent changes to reboot code. This fixes PV save/restore. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15567^2~164 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=fc229c860b262bf70dc647c61de927069641464a;p=xen.git Clean up recent changes to reboot code. This fixes PV save/restore. Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c b/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c index f7994fc1ce..02ee7f4728 100644 --- a/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c @@ -18,7 +18,6 @@ #include #include #include -#include #if defined(__i386__) || defined(__x86_64__) @@ -125,7 +124,7 @@ static void post_suspend(void) #endif -int __do_suspend(void *ignore) +int __xen_suspend(void) { int err; @@ -164,8 +163,6 @@ int __do_suspend(void *ignore) */ HYPERVISOR_suspend(virt_to_mfn(xen_start_info)); - shutting_down = SHUTDOWN_INVALID; - post_suspend(); gnttab_resume(); @@ -186,17 +183,3 @@ int __do_suspend(void *ignore) return err; } - -int kthread_create_on_cpu(int (*f)(void *arg), - void *arg, - const char *name, - int cpu) -{ - struct task_struct *p; - p = kthread_create(f, arg, name); - if (IS_ERR(p)) - return PTR_ERR(p); - kthread_bind(p, cpu); - wake_up_process(p); - return 0; -} diff --git a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c index bbda656021..1f19985c61 100644 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c @@ -8,13 +8,31 @@ #include #include #include -#include MODULE_LICENSE("Dual BSD/GPL"); +#define SHUTDOWN_INVALID -1 +#define SHUTDOWN_POWEROFF 0 +#define SHUTDOWN_SUSPEND 2 +/* Code 3 is SHUTDOWN_CRASH, which we don't use because the domain can only + * report a crash, not be instructed to crash! + * HALT is the same as POWEROFF, as far as we're concerned. The tools use + * the distinction when we return the reason code to them. + */ +#define SHUTDOWN_HALT 4 + +/* Ignore multiple shutdown requests. */ +static int shutting_down = SHUTDOWN_INVALID; + static void __shutdown_handler(void *unused); static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL); +#ifdef CONFIG_XEN +int __xen_suspend(void); +#else +#define __xen_suspend() 0 +#endif + static int shutdown_process(void *__unused) { static char *envp[] = { "HOME=/", "TERM=linux", @@ -41,21 +59,36 @@ static int shutdown_process(void *__unused) return 0; } +static int xen_suspend(void *__unused) +{ + __xen_suspend(); + shutting_down = SHUTDOWN_INVALID; + return 0; +} + +static int kthread_create_on_cpu(int (*f)(void *arg), + void *arg, + const char *name, + int cpu) +{ + struct task_struct *p; + p = kthread_create(f, arg, name); + if (IS_ERR(p)) + return PTR_ERR(p); + kthread_bind(p, cpu); + wake_up_process(p); + return 0; +} static void __shutdown_handler(void *unused) { int err; -#ifdef CONFIG_XEN if (shutting_down != SHUTDOWN_SUSPEND) err = kernel_thread(shutdown_process, NULL, CLONE_FS | CLONE_FILES); else - err = kthread_create_on_cpu(__do_suspend, NULL, "suspend", 0); -#else /* !CONFIG_XEN */ - err = kernel_thread(shutdown_process, NULL, - CLONE_FS | CLONE_FILES); -#endif /* !CONFIG_XEN */ + err = kthread_create_on_cpu(xen_suspend, NULL, "suspend", 0); if (err < 0) { printk(KERN_WARNING "Error creating shutdown process (%d): " @@ -71,8 +104,6 @@ static void shutdown_handler(struct xenbus_watch *watch, struct xenbus_transaction xbt; int err; - int cad_pid = 1; - if (shutting_down != SHUTDOWN_INVALID) return; @@ -98,7 +129,7 @@ static void shutdown_handler(struct xenbus_watch *watch, if (strcmp(str, "poweroff") == 0) shutting_down = SHUTDOWN_POWEROFF; else if (strcmp(str, "reboot") == 0) - kill_proc(cad_pid, SIGINT, 1); + kill_proc(1, SIGINT, 1); /* interrupt init */ else if (strcmp(str, "suspend") == 0) shutting_down = SHUTDOWN_SUSPEND; else if (strcmp(str, "halt") == 0) diff --git a/linux-2.6-xen-sparse/include/xen/reboot.h b/linux-2.6-xen-sparse/include/xen/reboot.h deleted file mode 100644 index 976372373c..0000000000 --- a/linux-2.6-xen-sparse/include/xen/reboot.h +++ /dev/null @@ -1,19 +0,0 @@ -#define SHUTDOWN_INVALID -1 -#define SHUTDOWN_POWEROFF 0 -#define SHUTDOWN_SUSPEND 2 -/* Code 3 is SHUTDOWN_CRASH, which we don't use because the domain can only - * report a crash, not be instructed to crash! - * HALT is the same as POWEROFF, as far as we're concerned. The tools use - * the distinction when we return the reason code to them. - */ -#define SHUTDOWN_HALT 4 - -/****************************************************************************** - * Stop/pickle callback handling. - */ - -/* Ignore multiple shutdown requests. */ -static int shutting_down = SHUTDOWN_INVALID; - -int kthread_create_on_cpu(int (*f)(void *), void *, const char *, int); -int __do_suspend(void *); diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index 48d256df16..fed6b33458 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -462,7 +462,7 @@ class HVMImageHandler(ImageHandler): def register_reboot_feature_watch(self): """ add xen store watch on control/feature-reboot """ - self.rebootModuleWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \ + self.rebootFeatureWatch = xswatch(self.vm.dompath + "/control/feature-reboot", \ self.hvm_reboot_feature) log.debug("hvm reboot feature watch registered")